module vfs.jsonreader;

import utils.log;

import std.stream;
public import std.json;
import exceptions;
import std.string;

class JSONReader {
    private string myFileName;

    public this(in string fileName) {
        myFileName = fileName;
    }

    public string getFileName() const shared {
        return myFileName;
    }

    public JSONValue read() shared {
        InputStream inputStream = new File(myFileName);
        string text;
        while (!inputStream.eof()) {
            text ~= inputStream.readLine();
        }
        return parseJSON(text);
    }

    public void read(void delegate(JSONValue value) dg) shared {
        dg(read());
    }
}
